//
//  JYJAnchorDataCollectionViewCell.m
//  HappyListen
//
//  Created by 冀永金 on 16/9/1.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "JYJAnchorDataCollectionViewCell.h"
#import "BaseTableView.h"
#import "JYJAnchorDataTableViewCell.h"
@interface JYJAnchorDataCollectionViewCell ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) BaseTableView *tableView;
@end
@implementation JYJAnchorDataCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createTableView];
    }
    return self;
}
- (void)setInfoDic:(NSDictionary *)infoDic {
    _infoDic = infoDic;
    [self.tableView reloadData];
}
- (void)createTableView {
    self.tableView = [[BaseTableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
    [self.contentView addSubview:_tableView];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerClass:[JYJAnchorDataTableViewCell class] forCellReuseIdentifier:@"pool"];
    self.tableView.scrollEnabled = NO;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
}
-(void)layoutSubviews {
    [super layoutSubviews];
    self.tableView.frame = self.contentView.bounds;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 4;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    JYJAnchorDataTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"pool" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor whiteColor];
    cell.labelOfLeftData.textColor = [UIColor lightGrayColor];
    NSArray *arr = @[@"性别",@"年龄",@"出生年月",@"星座"];
    cell.labelOfLeftData.text = arr[indexPath.row];
    if (indexPath.row == 0) {
        if ([[self.infoDic objectForKey:@"gender"] isEqualToString:@"1"]) {
            cell.labelOfRightData.text = @"男";
        }else {
            cell.labelOfRightData.text = @"女";

        }
    }else if (indexPath.row == 1) {
        cell.labelOfRightData.text = [NSString stringWithFormat:@"%@",self.infoDic[@"age"]];
    }else if (indexPath.row == 2) {
        cell.labelOfRightData.text = self.infoDic[@"birthday"];
    }else {
        cell.labelOfRightData.text = self.infoDic[@"constellation"];
    }
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 60;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
